﻿using System.Configuration;

namespace HCRS.Implementation
{
    using Common;
    using HCRS.Errors;
    using MSXML2;
    using System;
    using System.Data;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Xml;

    public class QueryXml
    {
        private Common.Email _Email = new Common.Email();
        private Functions _Functions = new Functions();
        private HotelClass _HotelClass = new HotelClass();
        /// <summary>
        /// 获得crs接口地址,用户名,密码
        /// </summary>
        public static string xmlgatewayurl = ConfigurationSettings.AppSettings["xmlgatewayurl"];
        public static string xmlpassword = ConfigurationSettings.AppSettings["xmlpassword"];
        public static string xmlusername = ConfigurationSettings.AppSettings["xmlusername"];

        private string CheckGUA(string guaRateDetail, string guaPlan, string guaRateClass)
        {
            if (((guaRateDetail == "") || (guaRateDetail == null)) || (guaRateDetail == "无改变"))
            {
                if (guaPlan != "")
                {
                    return guaPlan;
                }
                return guaRateClass;
            }
            return guaRateDetail;
        }

        /// <summary>
        /// 订单取消 从crs上取消
        /// </summary>
        /// <param name="propertyID">酒店id</param>
        /// <param name="confnum">订单确认码</param>
        /// <param name="errMSG">错误信息</param>
        /// <param name="cxlnum">取消确认码(返回)</param>
        /// <param name="status">预订状态(返回)</param>
        public void CxlResv(int propertyID, string confnum, out string errMSG, out string cxlnum, out string status)
        {
            string gzxmlcontent = string.Concat(new object[] { "<crsmessage  PropID='", propertyID, "'  user='", xmlusername, "'  pass='", xmlpassword, "'  msgtype='cancelresv'  ><reservation><confnum>", confnum, "</confnum></reservation></crsmessage>" });
            string responsexml = "";
            status = "";
            cxlnum = "";
            errMSG = "";
            GetQueryxml(gzxmlcontent, out responsexml, out errMSG);
            XmlDocument document = new XmlDocument();
            try
            {
                document.LoadXml(responsexml);
                XmlNode node = document.SelectSingleNode("//srvmessage");
                if (node != null)
                {
                    if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                    {
                        XmlNode node2 = document.SelectSingleNode("//resvdetail");
                        foreach (XmlElement element in node2)
                        {
                            if (element.Name == "status")
                            {
                                status = element.InnerText;
                            }
                            else if (element.Name == "cxlnum")
                            {
                                cxlnum = element.InnerText;
                            }
                        }
                    }
                    else
                    {
                        XmlNodeList list = document.SelectNodes("//error");
                        foreach (XmlNode node3 in list)
                        {
                            foreach (XmlElement element in node3.ChildNodes)
                            {
                                if (element.Name == "errormsg")
                                {
                                    errMSG = errMSG + "|" + element.InnerText;
                                }
                            }
                        }
                    }
                }
                else
                {
                    errMSG = "ErrnoResponse";
                }
            }
            catch (Exception exception)
            {
                errMSG = "ErrXMLdoc";
                this._Email.SendMail("[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + responsexml + " <br/>[exception]<br/> " + exception.Message + exception.StackTrace + exception.Source, "CxlResv接口抛出一个异常");
            }
        }

        /// <summary>
        /// 订单取消 从crs上取消
        /// </summary>
        /// <param name="propertyID">酒店id</param>
        /// <param name="verifycode">外部订单号</param>
        /// <param name="IATA">外部订单号</param>
        /// <param name="errMSG">错误信息</param>
        /// <param name="confnum">确认号（返回）</param>
        /// <param name="cxlnum">取消确认码(返回)</param>
        /// <param name="status">预订状态(返回)</param>
        public void CxlResv(int propertyID, string verifycode, string IATA, out string errMSG, out string confnum, out string cxlnum, out string status)
        {
            string gzxmlcontent = string.Concat(new object[] { "<crsmessage  PropID='", propertyID, "'  user='", xmlusername, "'  pass='", xmlpassword, "'  msgtype='cancelresv'  ><reservation><outconfnum>", verifycode, "</outconfnum><miscinfo><IATA>", IATA, "</IATA></miscinfo></reservation></crsmessage>" });
            string responsexml = "";
            status = "";
            cxlnum = "";
            errMSG = "";
            confnum = "";
            GetQueryxml(gzxmlcontent, out responsexml, out errMSG);
            XmlDocument document = new XmlDocument();
            try
            {
                document.LoadXml(responsexml);
                XmlNode node = document.SelectSingleNode("//srvmessage");
                if (node != null)
                {
                    if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                    {
                        XmlNode node2 = document.SelectSingleNode("//resvdetail");
                        foreach (XmlElement element in node2)
                        {
                            if (element.Name == "status")
                            {
                                status = element.InnerText;
                            }
                            else if (element.Name == "cxlnum")
                            {
                                cxlnum = element.InnerText;
                            }
                            else if (element.Name == "confnum")
                            {
                                confnum = element.InnerText;
                            }
                        }
                    }
                    else
                    {
                        XmlNodeList list = document.SelectNodes("//error");
                        foreach (XmlNode node3 in list)
                        {
                            foreach (XmlElement element in node3.ChildNodes)
                            {
                                if (element.Name == "errormsg")
                                {
                                    errMSG = errMSG + "|" + element.InnerText;
                                }
                            }
                        }
                    }
                }
                else
                {
                    errMSG = "ErrnoResponse";
                }
            }
            catch (Exception exception)
            {
                errMSG = "ErrXMLdoc";
                WebError.SendErrorEmail("<br>[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + responsexml + " <br/>[exception]<br/> " + exception.Message + exception.StackTrace + exception.Source);
            }
        }

        /// <summary>
        /// 通过外部订单号查询订单确认号
        /// </summary>
        /// <param name="outconfnum">outconfnum</param>
        /// <param name="pid">酒店PID</param>
        /// <param name="iata">Iata号</param>
        /// <returns></returns>
        public static string GetConfnumByOut(string outconfnum, string pid, string iata)
        {
            string responseText = "";
            string url = "http://222.73.234.173:8080/FogService/service/selfsystem";
            string xmlnamespace = "http://interfacexfire.webservice.syn.fogservice.thayer.com";
            string action = "getResvNumberByOutNumber";
            StringBuilder builder = new StringBuilder();
            builder.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?> ");
            builder.Append("<soap:Envelope  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> ");
            builder.Append("  <soap:Body> ");
            builder.Append("<getResvNumberByOutNumber xmlns=\"" + xmlnamespace + "\"> ");
            builder.Append("<in0>" + xmlusername + "</in0> ");
            builder.Append("<in1>" + xmlpassword + "</in1> ");
            builder.Append("<in2>" + outconfnum + "</in2> ");
            builder.Append("<in3>" + pid + "</in3> ");
            builder.Append("<in4>" + iata + "</in4> ");
            builder.Append("</getResvNumberByOutNumber> ");
            builder.Append("  </soap:Body> ");
            builder.Append("</soap:Envelope> ");
            if (TransferWebService(url, "utf-8", builder.ToString(), xmlnamespace, action, out responseText))
            {
                XmlDataDocument document = new XmlDataDocument();
                document.LoadXml(responseText);
                string innerText = document.GetElementsByTagName("ns1:out")[0].InnerText;
                if ((((innerText != "-10") && (innerText != "0")) && ((innerText != "-1") && (innerText != "-2"))) && (innerText != "-3"))
                {
                    return innerText;
                }
                return "null";
            }
            return "null";
        }

        /// <summary>
        /// 本方法查询getratemap,getavailmap，构造dataset并返回
        /// 这个方法查询指定酒店入住日期、房间数量、人数条件下的价格可用性信息。返回值中包括一个价格可用性dataset
        /// </summary>
        /// <param name="roomType">房型</param>
        /// <param name="rateClass">价格</param>
        /// <param name="strcheckinDate">入住日期</param>
        /// <param name="propertyID">酒店id</param>
        /// <param name="nights">房夜数</param>
        /// <param name="adults">成人数</param>
        /// <param name="children">儿童数</param>
        /// <param name="room">房间数</param>
        /// <param name="errMSG">错误</param>
        /// <param name="rateDateset">返回值</param>
        public void GetNewRateAvailMapSinglePlan(string roomType, string rateClass, string strcheckinDate, int propertyID, int nights, int adults, int children, int room, out string errMSG, out DataSet rateDateset)
        {
            this.GetNewRateAvailMapSinglePlan(roomType, rateClass, strcheckinDate, propertyID, nights, adults, children, room, 0, out errMSG, out rateDateset);
        }

        /// <summary>
        /// 本方法查询getratemap,getavailmap，构造dataset并返回
        /// 这个方法查询指定酒店入住日期、房间数量、人数条件下的价格可用性信息。返回值中包括一个价格可用性dataset
        /// </summary>
        /// <param name="roomType">房型</param>
        /// <param name="rateClass">价格</param>
        /// <param name="strcheckinDate">入住日期</param>
        /// <param name="propertyID">酒店id</param>
        /// <param name="nights">房夜数</param>
        /// <param name="adults">成人数</param>
        /// <param name="children">儿童数</param>
        /// <param name="room">房间数</param>
        /// <param name="language">int 中=0/英=1</param>
        /// <param name="errMSG">错误</param>
        /// <param name="rateDateset">返回值</param>
        public void GetNewRateAvailMapSinglePlan(string roomType, string rateClass, string strcheckinDate, int propertyID, int nights, int adults, int children, int room, int language, out string errMSG, out DataSet rateDateset)
        {
            string responsexml = "";
            string str5 = "";
            string str17 = "";
            string str18 = "";
            string str19 = "";
            errMSG = "";
            string str21 = Convert.ToDateTime(strcheckinDate).ToString("yyyy-MM-dd");
            string str22 = (language == 0) ? "cn" : "en";
            DataTable table = new DataTable();
            DataTable table2 = new DataTable();
            rateDateset = new DataSet();
            table = rateDateset.Tables.Add("plantable");
            table2 = rateDateset.Tables.Add("ratetable");
            table.Columns.Add("plancode", typeof(string));
            table.Columns.Add("planDesc", typeof(string));
            table.Columns.Add("planStatus", typeof(string));
            table.Columns.Add("planname", typeof(string));
            table.Columns.Add("roomDesc", typeof(string));
            table.Columns.Add("roomCode", typeof(string));
            table.Columns.Add("roomName", typeof(string));
            table.Columns.Add("rateDesc", typeof(string));
            table.Columns.Add("rateName", typeof(string));
            table.Columns.Add("rateCode", typeof(string));
            table.Columns.Add("Bed", typeof(bool));
            table.Columns.Add("BroadBand", typeof(bool));
            table.Columns.Add("Smoking", typeof(bool));
            table.Columns.Add("taxDesc", typeof(string));
            table.Columns.Add("resvgua", typeof(string));
            table.Columns.Add("resvcxl", typeof(string));
            table.Columns.Add("resvstatus", typeof(string));
            table.Columns.Add("resvguadesc", typeof(string));
            table.Columns.Add("resvcxldesc", typeof(string));
            table2.Columns.Add("plancode", typeof(string));
            table2.Columns.Add("Availdate", typeof(string));
            table2.Columns.Add("extraadult", typeof(string));
            table2.Columns.Add("Allotment", typeof(string));
            table2.Columns.Add("AvStat", typeof(string));
            table2.Columns.Add("MaxLos", typeof(string));
            table2.Columns.Add("MinLos", typeof(string));
            table2.Columns.Add("RateType", typeof(string));
            table2.Columns.Add("Gua", typeof(string));
            table2.Columns.Add("Cxl", typeof(string));
            table2.Columns.Add("PriceNoTax", typeof(decimal));
            table2.Columns.Add("CurrencyCode", typeof(string));
            table2.Columns.Add("BreakfastNum", typeof(int));
            table2.Columns.Add("BreakfastPay", typeof(decimal));
            table2.Columns.Add("BroadBand", typeof(bool));
            if ((roomType != "") && !(rateClass == ""))
            {
                string gzxmlcontent = string.Concat(new object[] { 
                    "<crsmessage  PropID='", propertyID, "'  user='", xmlusername, "'  pass='", xmlpassword, "'  msgtype='getonlineratemap'  language='", str22, "'  nolog='1'><options cascade='true'/><staydetail><filter>2</filter><channel>Website</channel><date>", str21, "</date><rateclass>", rateClass, "</rateclass><roomtype>", roomType, "</roomtype><nights>", nights, 
                    "</nights><rooms>", room, "</rooms><adults>", adults, "</adults><children>", children, "</children></staydetail></crsmessage>"
                 });
                try
                {
                    GetQueryxml(gzxmlcontent, out responsexml, out str19);
                    if (str19 != "")
                    {
                        errMSG = "<li>&#x63A5;&#x53E3;&#x8BBF;&#x95EE;&#x5931;&#x8D25;&#xFF1A;" + str19;
                    }
                    else
                    {
                        XmlDocument document = new XmlDocument();
                        document.LoadXml(responsexml);
                        XmlNode node = document.SelectSingleNode("//srvmessage");
                        if (node != null)
                        {
                            if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                            {
                                XmlNodeList list = document.SelectNodes("//ratedata");
                                foreach (XmlNode node2 in list)
                                {
                                    XmlNode node3 = node2.SelectSingleNode("plandetail");
                                    XmlNode node4 = node2.SelectSingleNode("resv");
                                    string str7 = "";
                                    string str8 = "";
                                    string str10 = "";
                                    string str11 = "";
                                    string str12 = "";
                                    string str13 = "";
                                    string innerText = "";
                                    string str15 = "";
                                    string str16 = "";
                                    str17 = "";
                                    str18 = "";
                                    string str9 = "";
                                    if (node4 != null)
                                    {
                                        XmlNode node5 = node4.SelectSingleNode("ResvGua");
                                        if (node5 != null)
                                        {
                                            innerText = node5.InnerText;
                                        }
                                        node5 = node4.SelectSingleNode("ResvCxl");
                                        if (node5 != null)
                                        {
                                            str15 = node5.InnerText;
                                        }
                                        node5 = node4.SelectSingleNode("ResvStatus");
                                        if (node5 != null)
                                        {
                                            str16 = node5.InnerText;
                                        }
                                        node5 = node4.SelectSingleNode("ResvGuaDesc");
                                        if (node5 != null)
                                        {
                                            str17 = node5.InnerText;
                                        }
                                        node5 = node4.SelectSingleNode("ResvCxlDesc");
                                        if (node5 != null)
                                        {
                                            str18 = node5.InnerText;
                                        }
                                    }
                                    foreach (XmlElement element in node3.ChildNodes)
                                    {
                                        if (element.Name == "Description")
                                        {
                                            str7 = element.InnerText;
                                        }
                                        else if (element.Name == "Status")
                                        {
                                            str8 = element.InnerText;
                                        }
                                        else if (element.Name == "plan")
                                        {
                                            str5 = element.InnerText;
                                        }
                                        else if (element.Name == "name")
                                        {
                                            str9 = element.InnerText;
                                        }
                                        else if (element.Name == "roomtype")
                                        {
                                            foreach (XmlElement element2 in element)
                                            {
                                                if (element2.Name == "Desc1")
                                                {
                                                    str10 = element2.InnerText;
                                                }
                                                else if (element2.Name == "name")
                                                {
                                                    str11 = element2.InnerText;
                                                }
                                            }
                                        }
                                        else if (element.Name == "rateclass")
                                        {
                                            foreach (XmlElement element3 in element)
                                            {
                                                if (element3.Name == "Desc1")
                                                {
                                                    str12 = element3.InnerText;
                                                }
                                                else if (element3.Name == "name")
                                                {
                                                    str13 = element3.InnerText;
                                                }
                                            }
                                        }
                                    }
                                    DataRow row = table.NewRow();
                                    row["plancode"] = str5;
                                    row["planDesc"] = str7;
                                    row["planStatus"] = str8;
                                    row["roomDesc"] = str10;
                                    row["roomName"] = str11;
                                    row["rateDesc"] = str12;
                                    row["rateName"] = str13;
                                    row["planname"] = str9;
                                    row["resvgua"] = innerText;
                                    row["resvcxl"] = str15;
                                    row["resvstatus"] = str16;
                                    row["resvguadesc"] = str17;
                                    row["resvcxldesc"] = str18;
                                    table.Rows.Add(row);
                                    XmlNodeList list2 = node2.SelectNodes("ratedetail");
                                    foreach (XmlNode node6 in list2)
                                    {
                                        string str23 = "";
                                        decimal num = 0M;
                                        int num2 = 0;
                                        int num3 = 0;
                                        string str30 = "";
                                        int num4 = 0;
                                        foreach (XmlElement element in node6.ChildNodes)
                                        {
                                            if (element.Name == "date")
                                            {
                                                str23 = element.InnerText;
                                            }
                                            else if (element.Name == "Total")
                                            {
                                                num = (element.InnerText == null) ? 0M : Convert.ToDecimal(element.InnerText);
                                            }
                                            else if (element.Name == "MaxLOS")
                                            {
                                                num2 = (element.InnerText == null) ? 0 : Convert.ToInt32(element.InnerText);
                                            }
                                            else if (element.Name == "MinLOS")
                                            {
                                                num3 = (element.InnerText == null) ? 0 : Convert.ToInt32(element.InnerText);
                                            }
                                            else if (element.Name == "AvStat")
                                            {
                                                str30 = element.InnerText;
                                            }
                                            else if (element.Name == "Allotment")
                                            {
                                                num4 = (element.InnerText == null) ? 0 : Convert.ToInt32(element.InnerText);
                                            }
                                        }
                                        string str32 = innerText;
                                        string str33 = str15;
                                        DataRow row2 = table2.NewRow();
                                        row2["Availdate"] = str23;
                                        row2["priceNoTax"] = num;
                                        row2["Allotment"] = num4.ToString();
                                        row2["AvStat"] = str30;
                                        row2["Gua"] = str32;
                                        row2["Cxl"] = str33;
                                        row2["MaxLos"] = num2.ToString();
                                        row2["MinLos"] = num3.ToString();
                                        table2.Rows.Add(row2);
                                    }
                                }
                                if (table2.Rows.Count < nights)
                                {
                                    errMSG = errMSG + "noEnoughAvailRoom";
                                }
                            }
                            else
                            {
                                errMSG = errMSG + "Error";
                            }
                        }
                        else
                        {
                            errMSG = errMSG + "noResponse";
                        }
                    }
                }
                catch (Exception exception)
                {
                    WebError.SendErrorEmail(exception);
                }
            }
        }

        /// <summary>
        /// 接口链接。根据请求返回信息
        /// </summary>
        /// <param name="gzxmlcontent">请求信息</param>
        /// <param name="responsexml">接口返回信息</param>
        /// <param name="errMSG">错误</param>
        public static void GetQueryxml(string gzxmlcontent, out string responsexml, out string errMSG)
        {
            ServerXMLHTTP rxmlhttp = new ServerXMLHTTPClass();
            errMSG = "";
            responsexml = "";
            try
            {
                rxmlhttp.open("POST", xmlgatewayurl, false, null, null);
                rxmlhttp.setRequestHeader("Content-Type", "text/xml;charset=utf-8");
                rxmlhttp.send(gzxmlcontent);
                if (rxmlhttp.readyState == 4)
                {
                    if (rxmlhttp.responseText.Trim() != "")
                    {
                        responsexml = rxmlhttp.responseText;
                        responsexml = responsexml.Replace("\n", "");
                        responsexml = responsexml.Replace(@"\", "");
                        responsexml = responsexml.Replace("\r", "");
                    }
                    else
                    {
                        responsexml = "";
                        errMSG = "ErrEmpty";
                        new Common.Email().SendMail("[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + rxmlhttp.responseText, "基类接口返回一个空值");
                    }
                }
            }
            catch (Exception exception)
            {
                errMSG = "ErrConnect";
                new Common.Email().SendMail("[send]<br/>" + gzxmlcontent + " <br/>[exception] <br/>" + exception.Message + exception.Source + exception.StackTrace, "基类接口查询抛出异常");
            }
            finally
            {
                rxmlhttp.abort();
            }
        }

        /// <summary>
        /// 本方法查询 getratemap,构造dataset并返回   区分中英文
        /// 
        /// </summary>
        /// <param name="roomType">房型代码</param>
        /// <param name="rateClass">价格代码</param>
        /// <param name="checkinDate">入住日期</param>
        /// <param name="propertyID">酒店id</param>
        /// <param name="nights">房夜数</param>
        /// <param name="adults">成人数</param>
        /// <param name="children">儿童数</param>
        /// <param name="room">房间数</param>
        /// <param name="language">int 中=0/英=1</param>
        /// <param name="errMSG">错误</param>
        /// <param name="rateDateset">返回值</param>
        public void GetRateMap(string roomType, string rateClass, string checkinDate, int propertyID, int nights, int adults, int children, int room, int language, out string errMSG, out DataSet rateDateset)
        {
            string str;
            string responsexml = "";
            string plancode = "";
            string str16 = "";
            errMSG = "";
            DataTable table = new DataTable();
            DataTable table2 = new DataTable();
            rateDateset = new DataSet();
            table = rateDateset.Tables.Add("plantable");
            table2 = rateDateset.Tables.Add("ratetable");
            table.Columns.Add("plancode", typeof(string));
            table.Columns.Add("planDesc", typeof(string));
            table.Columns.Add("planStatus", typeof(string));
            table.Columns.Add("planname", typeof(string));
            table.Columns.Add("roomDesc", typeof(string));
            table.Columns.Add("roomCode", typeof(string));
            table.Columns.Add("roomName", typeof(string));
            table.Columns.Add("rateDesc", typeof(string));
            table.Columns.Add("rateName", typeof(string));
            table.Columns.Add("rateCode", typeof(string));
            table.Columns.Add("Bed", typeof(bool));
            table.Columns.Add("BroadBand", typeof(bool));
            table.Columns.Add("Smoking", typeof(bool));
            table.Columns.Add("taxDesc", typeof(string));
            table2.Columns.Add("plancode", typeof(string));
            table2.Columns.Add("Availdate", typeof(string));
            table2.Columns.Add("extraadult", typeof(string));
            table2.Columns.Add("Allotment", typeof(string));
            table2.Columns.Add("AvStat", typeof(string));
            table2.Columns.Add("MaxLos", typeof(string));
            table2.Columns.Add("MinLos", typeof(string));
            table2.Columns.Add("RateType", typeof(string));
            table2.Columns.Add("Gua", typeof(string));
            table2.Columns.Add("Cxl", typeof(string));
            table2.Columns.Add("PriceNoTax", typeof(decimal));
            table2.Columns.Add("CurrencyCode", typeof(string));
            table2.Columns.Add("BreakfastNum", typeof(int));
            table2.Columns.Add("BreakfastPay", typeof(decimal));
            table2.Columns.Add("BroadBand", typeof(bool));
            string str26 = (language == 0) ? "cn" : "en";
            if ((rateClass.IndexOf(",") > 0) || (roomType.IndexOf(',') > 0))
            {
                string[] strArray = rateClass.Replace('|', ',').Split(new char[] { ',' });
                string[] strArray2 = roomType.Split(new char[] { ',' });
                str = string.Concat(new object[] { "<crsmessage  PropID='", propertyID, "'  user='", xmlusername, "'  pass='", xmlpassword, "'  msgtype='getratemap' language='", str26, "' nolog='1'><options cascade='true'/>" });
                for (int i = 0; i < strArray.Length; i++)
                {
                    for (int j = 0; j < strArray2.Length; j++)
                    {
                        str = string.Concat(new object[] { str, "<staydetail><channel>Website</channel><date>", checkinDate, "</date><rateclass>", strArray[i], "</rateclass><roomtype>", strArray2[j], "</roomtype><nights>", nights, "</nights><rooms>", room, "</rooms><adults>", adults, "</adults><children>", children, "</children></staydetail>" });
                    }
                }
                str = str + "</crsmessage>";
            }
            else
            {
                str = string.Concat(new object[] { 
                    "<crsmessage  PropID='", propertyID, "'  user='", xmlusername, "'  pass='", xmlpassword, "'  msgtype='getratemap' language='", str26, "' nolog='1'><options cascade='true'/><staydetail><channel>Website</channel><date>", checkinDate, "</date><rateclass>", rateClass, "</rateclass><roomtype>", roomType, "</roomtype><nights>", nights, 
                    "</nights><rooms>", room, "</rooms><adults>", adults, "</adults><children>", children, "</children></staydetail></crsmessage>"
                 });
            }
            try
            {
                GetQueryxml(str, out responsexml, out str16);
                if (str16 != "")
                {
                    errMSG = "<li>&#x63A5;&#x53E3;&#x8BBF;&#x95EE;&#x5931;&#x8D25;&#xFF1A;" + str16;
                }
                XmlDocument document = new XmlDocument();
                document.LoadXml(responsexml);
                XmlNode node = document.SelectSingleNode("//srvmessage");
                if (node != null)
                {
                    if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                    {
                        XmlNodeList list = document.SelectNodes("//ratedata");
                        foreach (XmlNode node2 in list)
                        {
                            XmlNode node3 = node2.SelectSingleNode("plandetail");
                            string plandesc = "";
                            string planname = "";
                            string innerText = "";
                            string roomdesc = "";
                            string roomname = "";
                            string roomCode = "";
                            string str13 = "";
                            string str15 = "";
                            string rateCode = "";
                            string guaPlan = "";
                            string guaRateClass = "";
                            string str22 = "";
                            string str23 = "";
                            foreach (XmlElement element in node3.ChildNodes)
                            {
                                if (element.Name == "Description")
                                {
                                    plandesc = element.InnerText;
                                }
                                else if (element.Name == "Status")
                                {
                                    innerText = element.InnerText;
                                }
                                else if (element.Name == "plan")
                                {
                                    plancode = element.InnerText;
                                }
                                else if (element.Name == "name")
                                {
                                    planname = element.InnerText;
                                }
                                else if (element.Name == "GuaranteeRule")
                                {
                                    guaPlan = element.InnerText;
                                }
                                else if (element.Name == "CancelRule")
                                {
                                    str22 = element.InnerText;
                                }
                                else if (element.Name == "roomtype")
                                {
                                    foreach (XmlElement element2 in element)
                                    {
                                        if (element2.Name == "Desc1")
                                        {
                                            roomdesc = element2.InnerText;
                                        }
                                        else if (element2.Name == "name")
                                        {
                                            roomname = element2.InnerText;
                                        }
                                        else if (element2.Name == "room")
                                        {
                                            roomCode = element2.InnerText;
                                        }
                                    }
                                }
                                else if (element.Name == "rateclass")
                                {
                                    foreach (XmlElement element3 in element)
                                    {
                                        if (element3.Name == "Desc1")
                                        {
                                            str13 = element3.InnerText;
                                        }
                                        else if (element3.Name == "name")
                                        {
                                            str15 = element3.InnerText;
                                        }
                                        else if (element3.Name == "GuaranteeRule")
                                        {
                                            guaRateClass = element3.InnerText;
                                        }
                                        else if (element3.Name == "CancelRule")
                                        {
                                            str23 = element3.InnerText;
                                        }
                                        else if (element3.Name == "rate")
                                        {
                                            rateCode = element3.InnerText;
                                        }
                                    }
                                }
                            }
                            DataRow row = table.NewRow();
                            row["plancode"] = plancode;
                            row["planDesc"] = plandesc;
                            row["planStatus"] = innerText;
                            row["roomDesc"] = roomdesc;
                            row["roomName"] = roomname;
                            row["roomCode"] = roomCode;
                            row["rateDesc"] = str13;
                            row["rateName"] = str15;
                            row["rateCode"] = rateCode;
                            row["planname"] = planname;
                            table.Rows.Add(row);
                            XmlNodeList list2 = node2.SelectNodes("ratedetail");
                            foreach (XmlNode node4 in list2)
                            {
                                string availdate = "";
                                int allotment = 0;
                                int allotMax = 0;
                                decimal extraadult = 0M;
                                decimal priceNoTax = 0M;
                                int maxLos = 0;
                                int minLos = 0;
                                string guaRateDetail = "";
                                string str24 = "";
                                string avStat = "";
                                foreach (XmlElement element in node4.ChildNodes)
                                {
                                    if (element.Name == "date")
                                    {
                                        availdate = element.InnerText;
                                    }
                                    else if (element.Name == "Allotment")
                                    {
                                        allotment = (element.InnerText == null) ? 0 : Convert.ToInt32(element.InnerText);
                                    }
                                    else if (element.Name == "ExtraPerson")
                                    {
                                        extraadult = (element.InnerText == null) ? 0M : Convert.ToDecimal(element.InnerText);
                                    }
                                    else if (element.Name == "Total")
                                    {
                                        priceNoTax = (element.InnerText == null) ? 0M : Convert.ToDecimal(element.InnerText);
                                    }
                                    else if (element.Name == "GUA")
                                    {
                                        guaRateDetail = element.InnerText;
                                    }
                                    else if (element.Name == "CXL")
                                    {
                                        str24 = element.InnerText;
                                    }
                                    else if (element.Name == "AvStat")
                                    {
                                        avStat = element.InnerText;
                                    }
                                    else if (element.Name == "MaxLOS")
                                    {
                                        maxLos = (element.InnerText == null) ? 0 : Convert.ToInt32(element.InnerText);
                                    }
                                    else if (element.Name == "MinLOS")
                                    {
                                        minLos = (element.InnerText == null) ? 0 : Convert.ToInt32(element.InnerText);
                                    }
                                    else if (element.Name == "AllotCeil")
                                    {
                                        allotMax = (element.InnerText == null) ? 0 : Convert.ToInt32(element.InnerText);
                                    }
                                }
                                string gua = this.CheckGUA(guaRateDetail, guaPlan, guaRateClass);
                                string cxl = this.CheckGUA(str24, str22, str23);
                                DataRow row2 = table2.NewRow();
                                row2["plancode"] = plancode;
                                row2["Availdate"] = availdate;
                                row2["extraadult"] = extraadult;
                                row2["PriceNoTax"] = priceNoTax;
                                row2["Allotment"] = allotment;
                                row2["AvStat"] = avStat;
                                row2["MaxLos"] = maxLos;
                                row2["MinLos"] = minLos;
                                row2["RateType"] = 0;
                                row2["Gua"] = gua;
                                row2["Cxl"] = cxl;
                                table2.Rows.Add(row2);
                                this._HotelClass.ModH_Cache(adults, language, propertyID, plancode, availdate, 0M, 0M, 0M, 0M, extraadult, 0M, allotment, allotMax, avStat, maxLos, minLos, rateCode, roomCode, "", availdate, availdate, roomdesc, plandesc, gua, cxl, priceNoTax, 0, planname, roomname);
                            }
                        }
                        if (table2.Rows.Count < nights)
                        {
                            errMSG = errMSG + "noEnoughAvailRoom";
                        }
                    }
                    else
                    {
                        errMSG = errMSG + "Error";
                    }
                }
                else
                {
                    errMSG = "noResponse";
                }
            }
            catch (Exception exception)
            {
                errMSG = "error" + exception.ToString() + str16;
            }
        }

        /// <summary>
        /// 根据iata号提取30天内的订单信息
        /// </summary>
        /// <param name="IATA">公司iata 无:900000</param>
        /// <param name="errMSG">out 类型的错误信息</param>
        /// <param name="arrResv">返回该iata号下30天内的订单信息</param>
        public void GetResv(string IATA, out string errMSG, out string[][] arrResv)
        {
            string responsexml = "";
            arrResv = null;
            errMSG = "";
            string gzxmlcontent = "<crsmessage  msgtype='getpropresv'  user='" + xmlusername + "'  pass='" + xmlpassword + "'><channel>Website</channel><bookdays>-30</bookdays><reservation><iata>" + IATA.ToString() + "</iata></reservation></crsmessage>";
            try
            {
                string str5;
                GetQueryxml(gzxmlcontent, out responsexml, out str5);
                errMSG = str5;
                XmlDocument document = new XmlDocument();
                if (responsexml.Length > 200)
                {
                    responsexml = responsexml.Replace("<remark>", "<remark><![CDATA[").Replace("</remark>", "]]></remark>");
                    document.LoadXml(responsexml);
                    XmlNode node = document.SelectSingleNode("//srvmessage");
                    if (node != null)
                    {
                        if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                        {
                            XmlNode node2 = document.SelectSingleNode("//resvdata");
                            arrResv = new string[node2.ChildNodes.Count][];
                            for (int i = 0; i < node2.ChildNodes.Count; i++)
                            {
                                XmlNode node3 = node2.ChildNodes.Item(i);
                                arrResv[i] = new string[0x33];
                                arrResv[i][0] = this.getXmlNode(node3, "prop");
                                string[] strArray = this.getXmlNode(node3, "staydetail//rateplan").Split(new char[] { '-' });
                                if ((strArray != null) && (strArray.Length == 2))
                                {
                                    arrResv[i][1] = strArray[0].ToString();
                                    arrResv[i][2] = strArray[1].ToString();
                                }
                                arrResv[i][3] = this.getXmlNode(node3, "staydetail//indate");
                                arrResv[i][4] = this.getXmlNode(node3, "staydetail//outdate");
                                arrResv[i][5] = this.getXmlNode(node3, "staydetail//departuredate");
                                arrResv[i][6] = this.getXmlNode(node3, "staydetail//nights");
                                arrResv[i][7] = this.getXmlNode(node3, "staydetail//rooms");
                                arrResv[i][8] = this.getXmlNode(node3, "guestinfo//firstname");
                                arrResv[i][9] = this.getXmlNode(node3, "guestinfo//lastname");
                                arrResv[i][10] = this.getXmlNode(node3, "guestinfo//email");
                                arrResv[i][11] = this.getXmlNode(node3, "guestinfo//phone");
                                arrResv[i][12] = this.getXmlNode(node3, "guestinfo//street1 ");
                                arrResv[i][13] = this.getXmlNode(node3, "guestinfo//street2 ");
                                arrResv[i][14] = this.getXmlNode(node3, "guestinfo//city");
                                arrResv[i][15] = this.getXmlNode(node3, "guestinfo//country");
                                arrResv[i][0x10] = "";
                                arrResv[i][0x11] = this.getXmlNode(node3, "guestinfo//postcode");
                                arrResv[i][0x12] = this.getXmlNode(node3, "ccinfo//cctype");
                                arrResv[i][0x13] = this.getXmlNode(node3, "ccinfo//ccnum");
                                arrResv[i][20] = this.getXmlNode(node3, "ccinfo//ccname");
                                string[] strArray2 = this.getXmlNode(node3, "ccinfo//ccexp").Split(new char[] { '/' });
                                if ((strArray2 != null) && (strArray2.Length >= 2))
                                {
                                    arrResv[i][0x15] = strArray2[0].ToString();
                                    arrResv[i][0x16] = strArray2[1].ToString();
                                }
                                else if (strArray2.Length == 1)
                                {
                                    arrResv[i][0x15] = strArray2[0].ToString();
                                }
                                else
                                {
                                    arrResv[i][0x15] = "";
                                    arrResv[i][0x16] = "";
                                }
                                arrResv[i][0x17] = "";
                                arrResv[i][0x18] = this.getXmlNode(node3, "miscinfo//iata");
                                arrResv[i][0x19] = this.getXmlNode(node3, "remarks");
                                arrResv[i][0x1a] = this.getXmlNode(node3, "confnum");
                                arrResv[i][0x1b] = this.getXmlNode(node3, "cxlnum");
                                arrResv[i][0x1c] = this.getXmlNode(node3, "status");
                                arrResv[i][0x1d] = this.getXmlNode(node3, "propname");
                                arrResv[i][30] = "";
                                arrResv[i][0x1f] = this.getXmlNode(node3, "bookedrates//totalrevenue");
                                arrResv[i][0x20] = this.getXmlNode(node3, "bookedrates//bookedrate");
                                arrResv[i][0x21] = this.getXmlNode(node3, "staydetail//adults");
                                arrResv[i][0x22] = this.getXmlNode(node3, "staydetail//children");
                                arrResv[i][0x23] = this.getXmlNode(node3, "staydetail//rateplanname") + this.getXmlNode(node3, "staydetail//roomtypename");
                                arrResv[i][0x24] = this.getXmlNode(node3, "staydetail//roomtypename");
                                arrResv[i][0x25] = this.getXmlNode(node3, "staydetail//rateplanname");
                                arrResv[i][0x26] = this.getXmlNode(node3, "cxlruledetail//description");
                                arrResv[i][0x27] = this.getXmlNode(node3, "guarruledetail//description");
                                arrResv[i][40] = "";
                                arrResv[i][0x29] = "";
                                arrResv[i][0x2a] = "0";
                                arrResv[i][0x2b] = "";
                                arrResv[i][0x2c] = "";
                                arrResv[i][0x2d] = "";
                                arrResv[i][0x2e] = "";
                                arrResv[i][0x2f] = this.getXmlNode(node3, "sign");
                                arrResv[i][0x30] = this.getXmlNode(node3, "timestamp");
                                arrResv[i][0x31] = this.getXmlNode(node3, "pmsno");
                                arrResv[i][50] = this.getXmlNode(node3, "staydetail//roomno");
                            }
                        }
                        else
                        {
                            errMSG = "接口返回失败信息:" + responsexml + "发送信息:" + gzxmlcontent;
                        }
                    }
                    else
                    {
                        errMSG = "没有符合条件的预订记录.信息返回信息:" + responsexml + "发送信息:" + gzxmlcontent;
                    }
                }
                else
                {
                    errMSG = "CRS return empty value:" + responsexml + "send info:" + gzxmlcontent;
                }
            }
            catch (Exception exception)
            {
                errMSG = "error" + exception.ToString() + "发送信息:" + gzxmlcontent.ToString() + "返回信息:" + responsexml.ToString();
            }
        }

        /// <summary>
        /// GetResv方法使用.返回xml节点下的值
        /// </summary>
        /// <param name="Node">传入的节点对象</param>
        /// <param name="strNode">传入的节点名称</param>
        /// <returns>返回节点名称下的值</returns>
        private string getXmlNode(XmlNode Node, string strNode)
        {
            int num;
            string str = "";
            if (strNode == "remark")
            {
                for (num = 0; num < Node.SelectSingleNode(strNode).ChildNodes.Count; num++)
                {
                    str = str + Node.SelectSingleNode(strNode).ChildNodes.Item(num).InnerText.ToString() + "  ";
                }
                return str;
            }
            if (strNode == "bookedrates//bookedrate")
            {
                for (num = 0; num < Node.SelectSingleNode("bookedrates").SelectNodes("bookedrate").Count; num++)
                {
                    str = (str + "|" + Node.SelectSingleNode("bookedrates").SelectNodes("bookedrate").Item(num).SelectSingleNode("date").InnerText.ToString()) + "," + Node.SelectSingleNode("bookedrates").SelectNodes("bookedrate").Item(num).SelectSingleNode("rate").InnerText.ToString();
                }
                return str;
            }
            return Node.SelectSingleNode(strNode).InnerText.ToString();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="roomType">房型</param>
        /// <param name="rateClass">价格代码</param>
        /// <param name="checkinDate">入住日期</param>
        /// <param name="propertyID">酒店id</param>
        /// <param name="nights">房夜数</param>
        /// <param name="adults">成人数</param>
        /// <param name="children">儿童数</param>
        /// <param name="room">房间数</param>
        /// <param name="firstname">客人姓</param>
        /// <param name="lastname">客人名</param>
        /// <param name="GuestAddressLine1">客人地址</param>
        /// <param name="GuestCity">客人所在城市</param>
        /// <param name="GuestStateCN">客人所在省/州</param>
        /// <param name="GuestZIP">客人所在地邮编</param>
        /// <param name="GuestCountry">客人所在国家</param>
        /// <param name="GuestPhone">客人电话</param>
        /// <param name="GuestEmail">客人电子邮件</param>
        /// <param name="ccname">卡主姓名</param>
        /// <param name="CCType">卡类型</param>
        /// <param name="CCNumber">卡号</param>
        /// <param name="CCExpYear">过期年份</param>
        /// <param name="CCExpMonth">过期月份</param>
        /// <param name="remark">订单备注</param>
        /// <param name="IATA">预订iata号</param>
        /// <param name="FrequentGuestID">常客id</param>
        /// <param name="SubSource"></param>
        /// <param name="errMSG">out类型的错误信息</param>
        /// <param name="confnum">确认码</param>
        /// <param name="status">订单状态</param>
        public void ModResv(string roomType, string rateClass, string checkinDate, int propertyID, short nights, short adults, short children, short room, string firstname, string lastname, string GuestAddressLine1, string GuestCity, string GuestStateCN, string GuestZIP, string GuestCountry, string GuestPhone, string GuestEmail, string ccname, string CCType, string CCNumber, string CCExpYear, string CCExpMonth, string remark, string IATA, string FrequentGuestID, string SubSource, out string errMSG, out string confnum, out string status)
        {
            string gzxmlcontent = string.Concat(new object[] { 
                "<crsmessage  PropID='", propertyID, "'  user='", xmlusername, "'  pass='", xmlpassword, "'  msgtype='modresv'  nolog='1'><options cascade='true'/><reservation><staydetail><date>", checkinDate, "</date><rateclass>", rateClass, "</rateclass><roomtype>", roomType, "</roomtype><nights>", nights, "</nights><rooms>", room, 
                "</rooms><adults>", adults, "</adults><children>", children, "</children></staydetail><guestinfo><lastname>", lastname, "</lastname><firstname>", firstname, "</firstname><title></title><street1>", GuestAddressLine1, "</street1><city>", GuestCity, "</city><state>", GuestStateCN, "</state><postcode>", GuestZIP, 
                "</postcode><country>", GuestCountry, "</country><phone>", GuestPhone, "</phone><email>", GuestEmail, "</email></guestinfo><ccinfo><ccname>", ccname, "</ccname><cctype>", CCType, "</cctype><ccnum>", CCNumber, "</ccnum><ccexp>", CCExpYear, "/", CCExpMonth, 
                "</ccexp></ccinfo><remarks><remark><![CDATA[", remark, "]]></remark><remark>[modify from DFB]</remark></remarks><miscinfo><IATA>", IATA, "</IATA><freqguestID>", FrequentGuestID, "</freqguestID><subsource>", SubSource, "</subsource></miscinfo></reservation></crsmessage>"
             });
            string responsexml = "";
            confnum = "";
            status = "";
            GetQueryxml(gzxmlcontent, out responsexml, out errMSG);
            if (errMSG == "")
            {
                XmlDocument document = new XmlDocument();
                errMSG = gzxmlcontent + responsexml + errMSG;
                try
                {
                    document.LoadXml(responsexml);
                    XmlNode node = document.SelectSingleNode("//srvmessage");
                    if (node != null)
                    {
                        errMSG = gzxmlcontent + responsexml + "<hr>";
                        if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                        {
                            XmlNode node2 = document.SelectSingleNode("//resvdetail");
                            foreach (XmlElement element in node2)
                            {
                                if (element.Name == "confnum")
                                {
                                    confnum = element.InnerText;
                                }
                                else if (element.Name == "status")
                                {
                                    status = element.InnerText;
                                }
                            }
                        }
                        else
                        {
                            XmlNodeList list = document.SelectNodes("//error");
                            foreach (XmlNode node3 in list)
                            {
                                foreach (XmlElement element in node3.ChildNodes)
                                {
                                    if (element.Name == "errormsg")
                                    {
                                        errMSG = errMSG + "|" + element.InnerText;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        errMSG = "ErrnoResponse";
                    }
                }
                catch (Exception exception)
                {
                    errMSG = "ErrXMLdoc";
                    this._Email.SendMail("[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + responsexml + " <br/>[exception]<br/> " + exception.Message + exception.StackTrace + exception.Source, "ModResv接口抛出一个异常");
                }
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="roomType">房型</param>
        /// <param name="rateClass">价格代码</param>
        /// <param name="checkinDate">入住日期</param>
        /// <param name="propertyID">酒店id</param>
        /// <param name="nights">房夜数</param>
        /// <param name="adults">成人数</param>
        /// <param name="children">儿童数</param>
        /// <param name="room">房间数</param>
        /// <param name="firstname">客人姓</param>
        /// <param name="lastname">客人名</param>
        /// <param name="GuestAddressLine1">客人地址</param>
        /// <param name="GuestCity">客人所在城市</param>
        /// <param name="GuestStateCN">客人所在省/州</param>
        /// <param name="GuestZIP">客人所在地邮编</param>
        /// <param name="GuestCountry">客人所在国家</param>
        /// <param name="GuestPhone">客人电话</param>
        /// <param name="GuestEmail">客人电子邮件</param>
        /// <param name="ccname">卡主姓名</param>
        /// <param name="CCType">卡类型</param>
        /// <param name="CCNumber">卡号</param>
        /// <param name="CCExpYear">过期年份</param>
        /// <param name="CCExpMonth">过期月份</param>
        /// <param name="remark">订单备注</param>
        /// <param name="from">订单来源</param>
        /// <param name="IATA">预订iata号</param>
        /// <param name="FrequentGuestID">常客id</param>
        /// <param name="SubSource"></param>
        /// <param name="errMSG">out类型的错误信息</param>
        /// <param name="confnum">确认码</param>
        /// <param name="status">订单状态</param>
        public void ModResv(string roomType, string rateClass, string checkinDate, int propertyID, short nights, short adults, short children, short room, string firstname, string lastname, string GuestAddressLine1, string GuestCity, string GuestStateCN, string GuestZIP, string GuestCountry, string GuestPhone, string GuestEmail, string ccname, string CCType, string CCNumber, string CCExpYear, string CCExpMonth, string remark, string from, string IATA, string FrequentGuestID, string SubSource, out string errMSG, out string confnum, out string status)
        {
            string gzxmlcontent = string.Concat(new object[] { 
                "<crsmessage  PropID='", propertyID, "'  user='", xmlusername, "'  pass='", xmlpassword, "'  msgtype='modresv'  nolog='1'><options cascade='true'/><reservation><staydetail><date>", checkinDate, "</date><rateclass>", rateClass, "</rateclass><roomtype>", roomType, "</roomtype><nights>", nights, "</nights><rooms>", room, 
                "</rooms><adults>", adults, "</adults><children>", children, "</children></staydetail><guestinfo><lastname>", lastname, "</lastname><firstname>", firstname, "</firstname><title></title><street1>", GuestAddressLine1, "</street1><city>", GuestCity, "</city><state>", GuestStateCN, "</state><postcode>", GuestZIP, 
                "</postcode><country>", GuestCountry, "</country><phone>", GuestPhone, "</phone><email>", GuestEmail, "</email></guestinfo><ccinfo><ccname>", ccname, "</ccname><cctype>", CCType, "</cctype><ccnum>", CCNumber, "</ccnum><ccexp>", CCExpYear, "/", CCExpMonth, 
                "</ccexp></ccinfo><remarks><remark><![CDATA[", remark, "]]></remark><remark>[modify from ", from, "]</remark></remarks><miscinfo><IATA>", IATA, "</IATA><freqguestID>", FrequentGuestID, "</freqguestID><subsource>", SubSource, "</subsource></miscinfo></reservation></crsmessage>"
             });
            string responsexml = "";
            confnum = "";
            status = "";
            GetQueryxml(gzxmlcontent, out responsexml, out errMSG);
            if (errMSG == "")
            {
                XmlDocument document = new XmlDocument();
                errMSG = gzxmlcontent + responsexml + errMSG;
                try
                {
                    document.LoadXml(responsexml);
                    XmlNode node = document.SelectSingleNode("//srvmessage");
                    if (node != null)
                    {
                        errMSG = gzxmlcontent + responsexml + "<hr>";
                        if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                        {
                            XmlNode node2 = document.SelectSingleNode("//resvdetail");
                            foreach (XmlElement element in node2)
                            {
                                if (element.Name == "confnum")
                                {
                                    confnum = element.InnerText;
                                }
                                else if (element.Name == "status")
                                {
                                    status = element.InnerText;
                                }
                            }
                        }
                        else
                        {
                            XmlNodeList list = document.SelectNodes("//error");
                            foreach (XmlNode node3 in list)
                            {
                                foreach (XmlElement element in node3.ChildNodes)
                                {
                                    if (element.Name == "errormsg")
                                    {
                                        errMSG = errMSG + "|" + element.InnerText;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        errMSG = "ErrnoResponse";
                    }
                }
                catch (Exception exception)
                {
                    errMSG = "ErrXMLdoc";
                    this._Email.SendMail("[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + responsexml + " <br/>[exception]<br/> " + exception.Message + exception.StackTrace + exception.Source, "ModResv接口抛出一个异常");
                }
            }
        }

        /// <summary>
        /// 订单修改 
        /// </summary>
        /// <param name="propertyID">酒店id</param>
        /// <param name="confnum">确认码</param>
        /// <param name="firstname">姓</param>
        /// <param name="lastname">名</param>
        /// <param name="GuestAddressLine1">客人地址</param>
        /// <param name="GuestPhone">客人电话</param>
        /// <param name="GuestEmail">客人电子邮件</param>
        /// <param name="remark">备注</param>
        /// <param name="errMSG">错误信息</param>
        /// <param name="status">订单状态</param>
        public void ModResvSimple(int propertyID, string confnum, string firstname, string lastname, string GuestAddressLine1, string GuestPhone, string GuestEmail, string remark, out string errMSG, out string status)
        {
            string gzxmlcontent = string.Concat(new object[] { 
                "<crsmessage  PropID='", propertyID, "'  user='", xmlusername, "'  pass='", xmlpassword, "'  msgtype='modresv'  nolog='1'><options cascade='true'/><reservation><confnum>", confnum, "</confnum><guestinfo><lastname>", lastname, "</lastname><firstname>", firstname, "</firstname><title></title><street1>", GuestAddressLine1, "</street1><phone>", GuestPhone, 
                "</phone><email>", GuestEmail, "</email></guestinfo><remarks><remark><![CDATA[", remark, "]]></remark><remark>[Modify from DFB]</remark></remarks></reservation></crsmessage>"
             });
            string responsexml = "";
            errMSG = "";
            status = "";
            GetQueryxml(gzxmlcontent, out responsexml, out errMSG);
            XmlDocument document = new XmlDocument();
            try
            {
                document.LoadXml(responsexml);
                XmlNode node = document.SelectSingleNode("//srvmessage");
                if (node != null)
                {
                    if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                    {
                        XmlNode node2 = document.SelectSingleNode("//resvdetail");
                        foreach (XmlElement element in node2)
                        {
                            if (element.Name == "status")
                            {
                                status = element.InnerText;
                            }
                        }
                    }
                    else
                    {
                        XmlNodeList list = document.SelectNodes("//error");
                        foreach (XmlNode node3 in list)
                        {
                            foreach (XmlElement element in node3.ChildNodes)
                            {
                                if (element.Name == "errormsg")
                                {
                                    errMSG = errMSG + "|" + element.InnerText;
                                }
                            }
                        }
                    }
                }
                else
                {
                    errMSG = "ErrnoResponse";
                }
            }
            catch (Exception exception)
            {
                errMSG = "ErrXMLdoc。";
                this._Email.SendMail("[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + responsexml + " <br/>[exception]<br/> " + exception.Message + exception.StackTrace + exception.Source, "ModResvSimple接口抛出一个异常");
            }
        }

        /// <summary>
        /// 订单修改 
        /// </summary>
        /// <param name="propertyID">酒店id</param>
        /// <param name="confnum">确认码</param>
        /// <param name="firstname">姓</param>
        /// <param name="lastname">名</param>
        /// <param name="GuestAddressLine1">客人地址</param>
        /// <param name="GuestPhone">客人电话</param>
        /// <param name="GuestEmail">客人电子邮件</param>
        /// <param name="remark">备注</param>
        /// <param name="from">订单来源</param>
        /// <param name="errMSG">错误信息</param>
        /// <param name="status">订单状态</param>
        public void ModResvSimple(int propertyID, string confnum, string firstname, string lastname, string GuestAddressLine1, string GuestPhone, string GuestEmail, string remark, string from, out string errMSG, out string status)
        {
            string gzxmlcontent = string.Concat(new object[] { 
                "<crsmessage  PropID='", propertyID, "'  user='", xmlusername, "'  pass='", xmlpassword, "'  msgtype='modresv'  nolog='1'><options cascade='true'/><reservation><confnum>", confnum, "</confnum><guestinfo><lastname>", lastname, "</lastname><firstname>", firstname, "</firstname><title></title><street1>", GuestAddressLine1, "</street1><phone>", GuestPhone, 
                "</phone><email>", GuestEmail, "</email></guestinfo><remarks><remark><![CDATA[", remark, "]]></remark><remark>[Modify from ", from, "]</remark></remarks></reservation></crsmessage>"
             });
            string responsexml = "";
            errMSG = "";
            status = "";
            GetQueryxml(gzxmlcontent, out responsexml, out errMSG);
            XmlDocument document = new XmlDocument();
            try
            {
                document.LoadXml(responsexml);
                XmlNode node = document.SelectSingleNode("//srvmessage");
                if (node != null)
                {
                    if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                    {
                        XmlNode node2 = document.SelectSingleNode("//resvdetail");
                        foreach (XmlElement element in node2)
                        {
                            if (element.Name == "status")
                            {
                                status = element.InnerText;
                            }
                        }
                    }
                    else
                    {
                        XmlNodeList list = document.SelectNodes("//error");
                        foreach (XmlNode node3 in list)
                        {
                            foreach (XmlElement element in node3.ChildNodes)
                            {
                                if (element.Name == "errormsg")
                                {
                                    errMSG = errMSG + "|" + element.InnerText;
                                }
                            }
                        }
                    }
                }
                else
                {
                    errMSG = "ErrnoResponse";
                }
            }
            catch (Exception exception)
            {
                errMSG = "ErrXMLdoc。";
                this._Email.SendMail("[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + responsexml + " <br/>[exception]<br/> " + exception.Message + exception.StackTrace + exception.Source, "ModResvSimple接口抛出一个异常");
            }
        }

        /// <summary>
        /// 本方法用在BOOKING STEP3，用来产生新预订，本方法返回预订的查询结果。
        /// 这个方法查询指定酒店，指定的roomType、rateClass、入住日期、房间数量、人数条件下的新预订信息。返回一个xml。
        /// </summary>
        /// <param name="roomType">房型描述</param>
        /// <param name="rateClass">价格代码</param>
        /// <param name="checkinDate">入住日期</param>
        /// <param name="propertyID">公司id</param>
        /// <param name="nights">房夜数</param>
        /// <param name="adults">成人数</param>
        /// <param name="children">儿童数</param>
        /// <param name="room">房间数</param>
        /// <param name="firstname">姓</param>
        /// <param name="lastname">名</param>
        /// <param name="GuestAddressLine1">客人地址</param>
        /// <param name="GuestCity">客人城市</param>
        /// <param name="GuestStateCN">客人所在省州</param>
        /// <param name="GuestZIP">客人邮编</param>
        /// <param name="GuestCountry">客人所在国家</param>
        /// <param name="GuestPhone">电话</param>
        /// <param name="GuestEmail">电子邮件</param>
        /// <param name="ccname">卡主姓名</param>
        /// <param name="CCType">卡类型</param>
        /// <param name="CCNumber">卡号</param>
        /// <param name="CCExpYear">过期年份</param>
        /// <param name="CCExpMonth">过期月份</param>
        /// <param name="remark">备注</param>
        /// <param name="IATA">公司iata</param>
        /// <param name="FrequentGuestID">常客id</param>
        /// <param name="SubSource"></param>
        /// <param name="errMSG">out类型的错误信息</param>
        /// <param name="confnum">订单确认码</param>
        /// <param name="status">预订状态</param>
        public void NewResv(string roomType, string rateClass, string checkinDate, int propertyID, int nights, int adults, int children, int room, string firstname, string lastname, string GuestAddressLine1, string GuestCity, string GuestStateCN, string GuestZIP, string GuestCountry, string GuestPhone, string GuestEmail, string ccname, string CCType, string CCNumber, string CCExpYear, string CCExpMonth, string remark, string IATA, string FrequentGuestID, string SubSource, out string errMSG, out string confnum, out string status)
        {
            string gzxmlcontent = string.Concat(new object[] { 
                "<crsmessage  PropID='", propertyID, "'  user='", xmlusername, "'  pass='", xmlpassword, "'  msgtype='newresv'  nolog='1'><options cascade='true'/><reservation><staydetail><date>", checkinDate, "</date><rateclass>", rateClass, "</rateclass><roomtype>", roomType, "</roomtype><nights>", nights, "</nights><rooms>", room, 
                "</rooms><adults>", adults, "</adults><children>", children, "</children></staydetail><guestinfo><lastname>", lastname, "</lastname><firstname>", firstname, "</firstname><title></title><street1>", GuestAddressLine1, "</street1><city>", GuestCity, "</city><state>", GuestStateCN, "</state><postcode>", GuestZIP, 
                "</postcode><country>", GuestCountry, "</country><phone>", GuestPhone, "</phone><email>", GuestEmail, "</email></guestinfo><ccinfo><ccname>", ccname, "</ccname><cctype>", CCType, "</cctype><ccnum>", CCNumber, "</ccnum><ccexp>", CCExpYear, "/", CCExpMonth, 
                "</ccexp></ccinfo><remarks><remark><![CDATA[", remark, "]]></remark><remark>[Booking from DFB]</remark></remarks><miscinfo><IATA>", IATA, "</IATA><freqguestID>", FrequentGuestID, "</freqguestID><subsource>", SubSource, "</subsource></miscinfo></reservation></crsmessage>"
             });
            string responsexml = "";
            confnum = "";
            status = "";
            GetQueryxml(gzxmlcontent, out responsexml, out errMSG);
            XmlDocument document = new XmlDocument();
            if (errMSG == "")
            {
                try
                {
                    document.LoadXml(responsexml);
                    XmlNamespaceManager nsmgr = new XmlNamespaceManager(document.NameTable);
                    nsmgr.AddNamespace("err", "http://www.hubs1.net/gxml/error");
                    XmlNode node = document.SelectSingleNode("//err:srvmessage", nsmgr);
                    if (node == null)
                    {
                        node = document.SelectSingleNode("srvmessage");
                    }
                    if (node != null)
                    {
                        if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                        {
                            XmlNode node2 = document.SelectSingleNode("//resvdetail");
                            if (node2.ChildNodes.Count > 0)
                            {
                                foreach (XmlElement element in node2)
                                {
                                    if (element.Name == "confnum")
                                    {
                                        confnum = element.InnerText;
                                    }
                                    else if (element.Name == "status")
                                    {
                                        status = element.InnerText;
                                    }
                                }
                            }
                            else
                            {
                                errMSG = "ErrConfnum";
                            }
                        }
                        else
                        {
                            XmlNodeList list = document.SelectNodes("//err:error", nsmgr);
                            foreach (XmlNode node3 in list)
                            {
                                foreach (XmlElement element in node3.ChildNodes)
                                {
                                    if (element.Name == "errormsg")
                                    {
                                        errMSG = errMSG + "|" + element.InnerText;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        errMSG = "ErrnoResponse";
                        Common.Email email = new Common.Email();
                        email.SendMail("[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + responsexml, "newresv接口返回一个空值");
                    }
                }
                catch (Exception exception)
                {
                    errMSG = "ErrXMLdoc";
                    new Common.Email().SendMail("[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + responsexml + " <br/>[exception]<br/> " + exception.Message + exception.StackTrace + exception.Source, "NewResv接口抛出一个异常");
                }
            }
        }

        /// <summary>
        /// 本方法用在BOOKING STEP3，用来产生新预订，本方法返回预订的查询结果。
        /// 这个方法查询指定酒店，指定的roomType、rateClass、入住日期、房间数量、人数条件下的新预订信息。返回一个xml。
        /// </summary>
        /// <param name="roomType">房型描述</param>
        /// <param name="rateClass">价格代码</param>
        /// <param name="checkinDate">入住日期</param>
        /// <param name="propertyID">公司id</param>
        /// <param name="nights">房夜数</param>
        /// <param name="adults">成人数</param>
        /// <param name="children">儿童数</param>
        /// <param name="room">房间数</param>
        /// <param name="firstname">姓</param>
        /// <param name="lastname">名</param>
        /// <param name="GuestAddressLine1">客人地址</param>
        /// <param name="GuestCity">客人城市</param>
        /// <param name="GuestStateCN">客人所在省州</param>
        /// <param name="GuestZIP">客人邮编</param>
        /// <param name="GuestCountry">客人所在国家</param>
        /// <param name="GuestPhone">电话</param>
        /// <param name="GuestEmail">电子邮件</param>
        /// <param name="ccname">卡主姓名</param>
        /// <param name="CCType">卡类型</param>
        /// <param name="CCNumber">卡号</param>
        /// <param name="CCExpYear">过期年份</param>
        /// <param name="CCExpMonth">过期月份</param>
        /// <param name="remark">备注</param>
        /// <param name="from">订单来源</param>
        /// <param name="IATA">公司iata</param>
        /// <param name="FrequentGuestID">常客id</param>
        /// <param name="SubSource"></param>
        /// <param name="errMSG">out类型的错误信息</param>
        /// <param name="confnum">订单确认码</param>
        /// <param name="status">预订状态</param>
        public void NewResv(string roomType, string rateClass, string checkinDate, int propertyID, int nights, int adults, int children, int room, string firstname, string lastname, string GuestAddressLine1, string GuestCity, string GuestStateCN, string GuestZIP, string GuestCountry, string GuestPhone, string GuestEmail, string ccname, string CCType, string CCNumber, string CCExpYear, string CCExpMonth, string remark, string from, string IATA, string FrequentGuestID, string SubSource, out string errMSG, out string confnum, out string status)
        {
            string gzxmlcontent = string.Concat(new object[] { 
                "<crsmessage  PropID='", propertyID, "'  user='", xmlusername, "'  pass='", xmlpassword, "'  msgtype='newresv'  nolog='1'><options cascade='true'/><reservation><staydetail><date>", checkinDate, "</date><rateclass>", rateClass, "</rateclass><roomtype>", roomType, "</roomtype><nights>", nights, "</nights><rooms>", room, 
                "</rooms><adults>", adults, "</adults><children>", children, "</children></staydetail><guestinfo><lastname>", lastname, "</lastname><firstname>", firstname, "</firstname><title></title><street1>", GuestAddressLine1, "</street1><city>", GuestCity, "</city><state>", GuestStateCN, "</state><postcode>", GuestZIP, 
                "</postcode><country>", GuestCountry, "</country><phone>", GuestPhone, "</phone><email>", GuestEmail, "</email></guestinfo><ccinfo><ccname>", ccname, "</ccname><cctype>", CCType, "</cctype><ccnum>", CCNumber, "</ccnum><ccexp>", CCExpMonth, "/", CCExpYear, 
                "</ccexp></ccinfo><remarks><remark><![CDATA[", remark, "]]></remark><remark>[Booking from ", from, "]</remark></remarks><miscinfo><IATA>", IATA, "</IATA><freqguestID>", FrequentGuestID, "</freqguestID><subsource>", SubSource, "</subsource></miscinfo></reservation></crsmessage>"
             });
            string responsexml = "";
            confnum = "";
            status = "";
            GetQueryxml(gzxmlcontent, out responsexml, out errMSG);
            XmlDocument document = new XmlDocument();
            if (errMSG == "")
            {
                try
                {
                    document.LoadXml(responsexml);
                    XmlNamespaceManager nsmgr = new XmlNamespaceManager(document.NameTable);
                    nsmgr.AddNamespace("err", "http://www.hubs1.net/gxml/error");
                    XmlNode node = document.SelectSingleNode("//err:srvmessage", nsmgr);
                    if (node == null)
                    {
                        node = document.SelectSingleNode("srvmessage");
                    }
                    if (node != null)
                    {
                        if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                        {
                            XmlNode node2 = document.SelectSingleNode("//resvdetail");
                            if (node2.ChildNodes.Count > 0)
                            {
                                foreach (XmlElement element in node2)
                                {
                                    if (element.Name == "confnum")
                                    {
                                        confnum = element.InnerText;
                                    }
                                    else if (element.Name == "status")
                                    {
                                        status = element.InnerText;
                                    }
                                }
                            }
                            else
                            {
                                errMSG = "ErrConfnum";
                            }
                        }
                        else
                        {
                            XmlNodeList list = document.SelectNodes("//err:error", nsmgr);
                            foreach (XmlNode node3 in list)
                            {
                                foreach (XmlElement element in node3.ChildNodes)
                                {
                                    if (element.Name == "errormsg")
                                    {
                                        errMSG = errMSG + "|" + element.InnerText;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        errMSG = "ErrnoResponse";
                        Common.Email email = new Common.Email();
                        email.SendMail("[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + responsexml, "newresv接口返回一个空值");
                    }
                }
                catch (Exception exception)
                {
                    errMSG = "ErrXMLdoc";
                    new Common.Email().SendMail("[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + responsexml + " <br/>[exception]<br/> " + exception.Message + exception.StackTrace + exception.Source, "NewResv接口抛出一个异常");
                }
            }
        }

        public void NewResv(string verifycode, string roomType, string rateClass, string checkinDate, int propertyID, int nights, int adults, int children, int room, string firstname, string lastname, string GuestAddressLine1, string GuestCity, string GuestStateCN, string GuestZIP, string GuestCountry, string GuestPhone, string GuestEmail, string ccname, string CCType, string CCNumber, string CCExpYear, string CCExpMonth, string remark, string IATA, string FrequentGuestID, string SubSource, out string errMSG, out string confnum, out string status)
        {
            string gzxmlcontent = string.Concat(new object[] { 
                "<crsmessage  PropID='", propertyID, "'  user='", xmlusername, "'  pass='", xmlpassword, "'  msgtype='newresv'  nolog='1'><options cascade='true'/><reservation><outconfnum>", verifycode, "</outconfnum><staydetail><date>", checkinDate, "</date><rateclass>", rateClass, "</rateclass><roomtype>", roomType, "</roomtype><nights>", nights, 
                "</nights><rooms>", room, "</rooms><adults>", adults, "</adults><children>", children, "</children></staydetail><guestinfo><lastname>", lastname, "</lastname><firstname>", firstname, "</firstname><title></title><street1>", GuestAddressLine1, "</street1><city>", GuestCity, "</city><state>", GuestStateCN, 
                "</state><postcode>", GuestZIP, "</postcode><country>", GuestCountry, "</country><phone>", GuestPhone, "</phone><email>", GuestEmail, "</email></guestinfo><ccinfo><ccname>", ccname, "</ccname><cctype>", CCType, "</cctype><ccnum>", CCNumber, "</ccnum><ccexp>", CCExpYear, 
                "/", CCExpMonth, "</ccexp></ccinfo><remarks><remark><![CDATA[", remark, "]]></remark><remark>[Booking from DFB]</remark></remarks><miscinfo><IATA>", IATA, "</IATA><freqguestID>", FrequentGuestID, "</freqguestID><subsource>", SubSource, "</subsource></miscinfo></reservation></crsmessage>"
             });
            string responsexml = "";
            confnum = "";
            status = "";
            GetQueryxml(gzxmlcontent, out responsexml, out errMSG);
            XmlDocument document = new XmlDocument();
            if (errMSG == "")
            {
                try
                {
                    document.LoadXml(responsexml);
                    XmlNamespaceManager nsmgr = new XmlNamespaceManager(document.NameTable);
                    nsmgr.AddNamespace("err", "http://www.hubs1.net/gxml/error");
                    XmlNode node = document.SelectSingleNode("//err:srvmessage", nsmgr);
                    if (node == null)
                    {
                        node = document.SelectSingleNode("srvmessage");
                    }
                    if (node != null)
                    {
                        if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                        {
                            XmlNode node2 = document.SelectSingleNode("//resvdetail");
                            if (node2.ChildNodes.Count > 0)
                            {
                                foreach (XmlElement element in node2)
                                {
                                    if (element.Name == "confnum")
                                    {
                                        confnum = element.InnerText;
                                    }
                                    else if (element.Name == "status")
                                    {
                                        status = element.InnerText;
                                    }
                                }
                            }
                            else
                            {
                                errMSG = "ErrConfnum";
                            }
                        }
                        else
                        {
                            XmlNodeList list = document.SelectNodes("//err:error", nsmgr);
                            foreach (XmlNode node3 in list)
                            {
                                foreach (XmlElement element in node3.ChildNodes)
                                {
                                    if (element.Name == "errormsg")
                                    {
                                        errMSG = errMSG + "|" + element.InnerText;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        errMSG = "ErrnoResponse";
                        Common.Email email = new Common.Email();
                        email.SendMail("[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + responsexml, "newresv接口返回一个空值");
                    }
                }
                catch (Exception exception)
                {
                    errMSG = "ErrXMLdoc";
                    new Common.Email().SendMail("[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + responsexml + " <br/>[exception]<br/> " + exception.Message + exception.StackTrace + exception.Source, "NewResv接口抛出一个异常");
                }
            }
        }

        public void NewResv(string verifycode, string roomType, string rateClass, string checkinDate, int propertyID, int nights, int adults, int children, int room, string firstname, string lastname, string GuestAddressLine1, string GuestCity, string GuestStateCN, string GuestZIP, string GuestCountry, string GuestPhone, string GuestEmail, string ccname, string CCType, string CCNumber, string CCExpYear, string CCExpMonth, string remark, string from, string IATA, string FrequentGuestID, string SubSource, out string errMSG, out string confnum, out string status)
        {
            string gzxmlcontent = string.Concat(new object[] { 
                "<crsmessage  PropID='", propertyID, "'  user='", xmlusername, "'  pass='", xmlpassword, "'  msgtype='newresv'  nolog='1'><options cascade='true'/><reservation><outconfnum>", verifycode, "</outconfnum><staydetail><date>", checkinDate, "</date><rateclass>", rateClass, "</rateclass><roomtype>", roomType, "</roomtype><nights>", nights, 
                "</nights><rooms>", room, "</rooms><adults>", adults, "</adults><children>", children, "</children></staydetail><guestinfo><lastname>", lastname, "</lastname><firstname>", firstname, "</firstname><title></title><street1>", GuestAddressLine1, "</street1><city>", GuestCity, "</city><state>", GuestStateCN, 
                "</state><postcode>", GuestZIP, "</postcode><country>", GuestCountry, "</country><phone>", GuestPhone, "</phone><email>", GuestEmail, "</email></guestinfo><ccinfo><ccname>", ccname, "</ccname><cctype>", CCType, "</cctype><ccnum>", CCNumber, "</ccnum><ccexp>", CCExpYear, 
                "/", CCExpMonth, "</ccexp></ccinfo><remarks><remark><![CDATA[", remark, "]]></remark><remark>[Booking from ", from, "]</remark></remarks><miscinfo><IATA>", IATA, "</IATA><freqguestID>", FrequentGuestID, "</freqguestID><subsource>", SubSource, "</subsource></miscinfo></reservation></crsmessage>"
             });
            string responsexml = "";
            confnum = "";
            status = "";
            GetQueryxml(gzxmlcontent, out responsexml, out errMSG);
            XmlDocument document = new XmlDocument();
            if (errMSG == "")
            {
                try
                {
                    document.LoadXml(responsexml);
                    XmlNamespaceManager nsmgr = new XmlNamespaceManager(document.NameTable);
                    nsmgr.AddNamespace("err", "http://www.hubs1.net/gxml/error");
                    XmlNode node = document.SelectSingleNode("//err:srvmessage", nsmgr);
                    if (node == null)
                    {
                        node = document.SelectSingleNode("srvmessage");
                    }
                    if (node != null)
                    {
                        if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                        {
                            XmlNode node2 = document.SelectSingleNode("//resvdetail");
                            if (node2.ChildNodes.Count > 0)
                            {
                                foreach (XmlElement element in node2)
                                {
                                    if (element.Name == "confnum")
                                    {
                                        confnum = element.InnerText;
                                    }
                                    else if (element.Name == "status")
                                    {
                                        status = element.InnerText;
                                    }
                                }
                            }
                            else
                            {
                                errMSG = "ErrConfnum";
                            }
                        }
                        else
                        {
                            XmlNodeList list = document.SelectNodes("//err:error", nsmgr);
                            foreach (XmlNode node3 in list)
                            {
                                foreach (XmlElement element in node3.ChildNodes)
                                {
                                    if (element.Name == "errormsg")
                                    {
                                        errMSG = errMSG + "|" + element.InnerText;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        errMSG = "ErrnoResponse";
                        Common.Email email = new Common.Email();
                        email.SendMail("[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + responsexml, "newresv接口返回一个空值");
                    }
                }
                catch (Exception exception)
                {
                    errMSG = "ErrXMLdoc";
                    new Common.Email().SendMail("[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + responsexml + " <br/>[exception]<br/> " + exception.Message + exception.StackTrace + exception.Source, "NewResv接口抛出一个异常");
                }
            }
        }

        /// <summary>
        /// 本方法用在用来产生新预订，特殊新预订，增加新节点本方法返回预订的查询结果。
        /// 这个方法查询指定酒店，指定的roomType、rateClass、入住日期、房间数量、人数条件下的新预订信息。返回一个xml。
        /// </summary>
        /// <param name="msgtype">接口名称</param>
        /// <param name="roomType">房型描述</param>
        /// <param name="rateClass">价格代码</param>
        /// <param name="checkinDate">入住日期</param>
        /// <param name="propertyID">公司id</param>
        /// <param name="nights">房夜数</param>
        /// <param name="adults">成人数</param>
        /// <param name="children">儿童数</param>
        /// <param name="room">房间数</param>
        /// <param name="firstname">姓</param>
        /// <param name="lastname">名</param>
        /// <param name="GuestAddressLine1">客人地址</param>
        /// <param name="GuestCity">客人城市</param>
        /// <param name="GuestStateCN">客人所在省州</param>
        /// <param name="GuestZIP">客人邮编</param>
        /// <param name="GuestCountry">客人所在国家</param>
        /// <param name="GuestPhone">电话</param>
        /// <param name="GuestEmail">电子邮件</param>
        /// <param name="ccname">卡主姓名</param>
        /// <param name="CCType">卡类型</param>
        /// <param name="CCNumber">卡号</param>
        /// <param name="CCExpYear">过期年份</param>
        /// <param name="CCExpMonth">过期月份</param>
        /// <param name="remark">备注</param>
        /// <param name="from">订单来源</param>
        /// <param name="IATA">公司iata</param>
        /// <param name="FrequentGuestID">常客id</param>
        /// <param name="SubSource"></param>
        /// <param name="specialXml">特殊xml节点字符串</param>
        /// <param name="errMSG">out类型的错误信息</param>
        /// <param name="confnum">订单确认码</param>
        /// <param name="status">预订状态</param>
        public void NewResv(string msgtype, string roomType, string rateClass, string checkinDate, int propertyID, int nights, int adults, int children, int room, string firstname, string lastname, string GuestAddressLine1, string GuestCity, string GuestStateCN, string GuestZIP, string GuestCountry, string GuestPhone, string GuestEmail, string ccname, string CCType, string CCNumber, string CCExpYear, string CCExpMonth, string remark, string from, string IATA, string FrequentGuestID, string SubSource, string specialXml, out string errMSG, out string confnum, out string status)
        {
            string gzxmlcontent = string.Concat(new object[] { 
                "<crsmessage  PropID='", propertyID, "'  user='", xmlusername, "'  pass='", xmlpassword, "'  msgtype='", msgtype, "'  nolog='1'><options cascade='true'/><reservation><staydetail><date>", checkinDate, "</date><rateclass>", rateClass, "</rateclass><roomtype>", roomType, "</roomtype><nights>", nights, 
                "</nights><rooms>", room, "</rooms><adults>", adults, "</adults><children>", children, "</children></staydetail><guestinfo><lastname>", lastname, "</lastname><firstname>", firstname, "</firstname><title></title><street1>", GuestAddressLine1, "</street1><city>", GuestCity, "</city><state>", GuestStateCN, 
                "</state><postcode>", GuestZIP, "</postcode><country>", GuestCountry, "</country><phone>", GuestPhone, "</phone><email>", GuestEmail, "</email></guestinfo>", specialXml, "<ccinfo><ccname>", ccname, "</ccname><cctype>", CCType, "</cctype><ccnum>", CCNumber, 
                "</ccnum><ccexp>", CCExpYear, "/", CCExpMonth, "</ccexp></ccinfo><remarks><remark><![CDATA[", remark, "]]></remark><remark>[Booking from ", from, "]</remark></remarks><miscinfo><IATA>", IATA, "</IATA><freqguestID>", FrequentGuestID, "</freqguestID><subsource>", SubSource, "</subsource></miscinfo></reservation></crsmessage>"
             });
            string responsexml = "";
            confnum = "";
            status = "";
            GetQueryxml(gzxmlcontent, out responsexml, out errMSG);
            XmlDocument document = new XmlDocument();
            if (errMSG == "")
            {
                try
                {
                    document.LoadXml(responsexml);
                    XmlNamespaceManager nsmgr = new XmlNamespaceManager(document.NameTable);
                    nsmgr.AddNamespace("err", "http://www.hubs1.net/gxml/error");
                    XmlNode node = document.SelectSingleNode("//err:srvmessage", nsmgr);
                    if (node == null)
                    {
                        node = document.SelectSingleNode("srvmessage");
                    }
                    if (node != null)
                    {
                        if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                        {
                            XmlNode node2 = document.SelectSingleNode("//resvdetail");
                            if (node2.ChildNodes.Count > 0)
                            {
                                foreach (XmlElement element in node2)
                                {
                                    if (element.Name == "confnum")
                                    {
                                        confnum = element.InnerText;
                                    }
                                    else if (element.Name == "status")
                                    {
                                        status = element.InnerText;
                                    }
                                }
                            }
                            else
                            {
                                errMSG = "ErrConfnum";
                            }
                        }
                        else
                        {
                            XmlNodeList list = document.SelectNodes("//err:error", nsmgr);
                            foreach (XmlNode node3 in list)
                            {
                                foreach (XmlElement element in node3.ChildNodes)
                                {
                                    if (element.Name == "errormsg")
                                    {
                                        errMSG = errMSG + "|" + element.InnerText;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        errMSG = "ErrnoResponse";
                        Common.Email email = new Common.Email();
                        email.SendMail("[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + responsexml, "newresv接口返回一个空值");
                    }
                }
                catch (Exception exception)
                {
                    errMSG = "ErrXMLdoc";
                    new Common.Email().SendMail("[send]<br/>" + gzxmlcontent + " <br/>[response]<br/> " + responsexml + " <br/>[exception]<br/> " + exception.Message + exception.StackTrace + exception.Source, "NewResv接口抛出一个异常");
                }
            }
        }

        /// <summary>
        /// WebService调用
        /// </summary>
        /// <param name="url">Url</param>
        /// <param name="encode">字符编码</param>
        /// <param name="strRequest">PostXml soap:Envelope</param>
        /// <param name="xmlnamespace">xml命名空间</param>
        /// <param name="action">调用方法</param>
        /// <param name="responseText">返回xml文档</param>
        /// <returns></returns>
        public static bool TransferWebService(string url, string encode, string strRequest, string xmlnamespace, string action, out string responseText)
        {
            ServerXMLHTTP rxmlhttp = new ServerXMLHTTPClass();
            try
            {
                rxmlhttp.open("POST", url, false, null, null);
                rxmlhttp.setRequestHeader("Content-Type", "text/xml; charset=" + encode + "");
                rxmlhttp.setRequestHeader("SOAPAction", xmlnamespace + "/" + action);
                rxmlhttp.send(strRequest);
                if (rxmlhttp.readyState != 4)
                {
                    throw new Exception("未响应，超时！");
                }
                responseText = rxmlhttp.responseText;
                return true;
            }
            catch (Exception exception)
            {
                responseText = exception.Message;
                return false;
            }
        }
    }
}

